#include "Point3D.h"

#include <cstdlib>
#include <cmath>

Point3D::Point3D(double i_x, double i_y, double i_z)
  {
  m_x[0] = i_x;
  m_x[1] = i_y;
  m_x[2] = i_z;
  }


Point3D::~Point3D(void)
  {
  }

double Point3D::GetX() const
  {
  return m_x[0];
  }

double Point3D::GetY() const
  {
  return m_x[1];
  }

double Point3D::GetZ() const
  {
  return m_x[2];
  }

double Point3D::Dist(const Point3D& i_other) const
  {
  return std::sqrt((m_x[0] - i_other.GetX()) * (m_x[0] - i_other.GetX()) +
                   (m_x[1] - i_other.GetY()) * (m_x[1] - i_other.GetY()) +
                   (m_x[2] - i_other.GetZ()) * (m_x[2] - i_other.GetZ()));
  }

void Point3D::SetRandom(int i_max_value = 50)
  {
  for (int i = 0; i < 3; ++i)
    {
    m_x[i] = std::rand() % (2 * i_max_value + 1) - i_max_value;
    }
  }

std::ostream& operator << (std::ostream& o_stream, const Point3D& i_point)
  {
  o_stream << "(" << i_point.m_x[0] << ", " << i_point.m_x[1] << ", " << i_point.m_x[2] << ")";
  return o_stream;
  }